//
//  JYLineView.m
//  OneToOne
//
//  Created by Herui on 14/11/25.
//  Copyright (c) 2014年 jiayuan. All rights reserved.
//

#import "HHLineView.h"

@implementation HHLineView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithCoder:(NSCoder *)aDecoder
{
    self = [super initWithCoder:aDecoder];
    if (self) {
        self.userInteractionEnabled = NO;
        [self customizeUI];
    }
    return self;
}

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.userInteractionEnabled = NO;
        [self customizeUI];
    }
    return self;
}

- (void)customizeUI
{
    CGFloat height = self.frame.size.height;
    CGRect rect = self.frame;
    
        //
    CGFloat y = self.frame.origin.y;
    UILabel *lineLabel;
    if (y == 0) {
        lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, rect.size.width, 0.5)];

    } else {
        lineLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, height-0.5, rect.size.width, 0.5)];

    }
    lineLabel.backgroundColor = UIColorFromRGB(0xdddddd);
    lineLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;
    [self addSubview:lineLabel];
    
}

+ (HHLineView *)lineViewWithY:(CGFloat)y
{
    HHLineView *line = [[HHLineView alloc] initWithFrame:CGRectMake(0, y, kCurrentWidth, 1)];
    return line;
}

@end
